package DBManager;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ResourceBundle;

public class DBConnection {
    
    public static String driver, url, username,password;
    
    public DBConnection()
    {
        //Get the data from the dbcredentials.properties
        ResourceBundle settings = 
                ResourceBundle.getBundle("dbcredentials");
        driver = settings.getString("driver");
        url = settings.getString("url");
        username = settings.getString("username");
        password = settings.getString("password");
             
    }
    
    public Connection getConnection()
    {
        try{
            //Connect to the driver
            Class.forName(driver);
            
            //acquires database connection
            Connection conn =
              DriverManager.getConnection(url,username,password);
            
            //retun connection
            return conn;
        }
        catch(SQLException ex){
        }
        catch(ClassNotFoundException ex){
        }
        
        return null;
    }
    
    
}
